package com.ziulife.dao;

import com.ziulife.model.User;

import java.util.List;

public class UserDaoImpl extends BaseDao<User> implements UserDao{

    @Override
    public List<User> query(String phone) {
        String sql = "SELECT * FROM `user` WHERE 1=1";
        if(phone!=null && !"".equals(phone))
            sql = sql + " AND phone like '%"+phone+"%'";
        sql += " AND TO_DAYS(create_time) = TO_DAYS(NOW()) ORDER BY create_time DESC";
        return super.getList(sql);
    }

    @Override
    public User getLikeByPhone(String phone_number) {
        String sql = "SELECT phone, nickname, station_address FROM user WHERE phone LIKE '%"+phone_number+"'";
        return super.get(sql);
    }

    @Override
    public int insertAddress(String address, String phone_number) {
        String sql = "update user set station_address=? where phone=?";
        return super.update(sql, address, phone_number);
    }




}
